package com.uzai.console.web.meraccdetail;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.dto.meraccdetail.MerAccDetailQuery;
import com.uzai.console.enums.MerAccDetailSourceTypeEnum;
import com.uzai.console.service.meraccdetail.MerAccDetailService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.meraccdetail.MerAccDetailInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 设备监控
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "账户余额明细",tags = "交易明细|账户余额明细")
@ApiSort(17)
@RestController
public class MerAccDetailController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MerAccDetailController.class);

    @Autowired
    private MerAccDetailService merAccDetailService;

    @ApiOperation(value = "分页查询账户余额明细列表", notes = "分页查询账户余额明细列表", response = MerAccDetailInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/merAccDetail/findMerAccDetailList")
    public Object findMerAccDetailList(@RequestBody MerAccDetailQuery merAccDetailQuery){
        return merAccDetailService.findMerAccDetailList(merAccDetailQuery);
    }

    @ApiOperation(value = "查询交易类型下拉列表", notes = "查询交易类型下拉列表", response = SelectKeyVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/merAccDetail/findTypeListSelected")
    public Object findTypeListSelected(){
        List<SelectKeyVo> selectKeyVoList = new ArrayList<>();
        MerAccDetailSourceTypeEnum[] merAccDetailSourceTypeEnums = MerAccDetailSourceTypeEnum.values();
        if(merAccDetailSourceTypeEnums != null && merAccDetailSourceTypeEnums.length > 0){
            for (MerAccDetailSourceTypeEnum merAccDetailSourceTypeEnum : merAccDetailSourceTypeEnums){
                SelectKeyVo selectKeyVo = new SelectKeyVo();
                selectKeyVo.setKey(String.valueOf(merAccDetailSourceTypeEnum.getId()));
                selectKeyVo.setValue(merAccDetailSourceTypeEnum.getDesc());
                selectKeyVoList.add(selectKeyVo);
            }
        }
        return selectKeyVoList;
    }

}
